package com.skymxc.skinpractice

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import com.skymxc.skin.SkinManager
import com.skymxc.skinpractice.databinding.ActivitySkinManagerBinding

/**
 * 皮肤管理
 */
class SkinManagerActivity : Activity() {

    private val skinAPP1 = "/skintheme1-debug.apk"
    private val skinAPP2 = "/skintheme2-debug.apk"
    lateinit var binding:ActivitySkinManagerBinding
    @SuppressLint("UseCompatLoadingForDrawables")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySkinManagerBinding.inflate(layoutInflater)
        setContentView(binding.root)
//        setSupportActionBar(binding.skinManagerToolbar)
//        supportActionBar?.setDisplayHomeAsUpEnabled(true)

        binding.skinManagerBtnChange.setOnClickListener {
           SkinManager.loadSkin( cacheDir.absolutePath+skinAPP1)

        }
        binding.skinManagerBtnChange2.setOnClickListener {
            SkinManager.loadSkin( cacheDir.absolutePath+skinAPP2)
        }
        binding.skinManagerBtnReset.setOnClickListener {
            SkinManager.loadSkin(null)
        }
        binding.skinManagerBtnToThird.setOnClickListener {
            startActivity(Intent(this@SkinManagerActivity,ThirdMainActivity::class.java))
        }
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when(item.itemId){
            android.R.id.home -> onBackPressed()
        }
        return super.onOptionsItemSelected(item)
    }
}